package com.sh.设计模式.策略模式以及优化.lambda表达式优化;

public class LambdaStrategyDemo {
    public static void main(String[] args) {
        DiscountStrategy normal = (double price) -> {
            System.out.println("普通用户，不打折");
            double result = price;
            return result;
        };
        DiscountStrategy member = (double price) -> {
            System.out.println("会员用户，打九折");
            if (price > 200) {
                System.out.println("满200元，额外减20元");
                return price * 0.9 - 20;
            } else {
                return price * 0.9;
            }
        };
        DiscountStrategy vip = (double price) -> {
            System.out.println("VIP用户，打八折");
            double discount = price * 0.8;
            System.out.println("折后价：" + discount);
            return discount;
        };

        System.out.println("普通用户：" + normal.applyDiscount(100));
        System.out.println("会员用户：" + member.applyDiscount(100));
        System.out.println("VIP用户：" + vip.applyDiscount(100));
    }
}
